<?php
/**
 *
 * 登录验证
 *
 */
namespace app\admin\middleware;

use app\admin\service\auth\AdminService;

class CheckLogin
{
    public function handle($request, \Closure $next){
        $adminService = new AdminService();
        if (!$adminService->checkToken()){
            return json(['error'=>10001, 'msg'=>'登录超时']);
        }

        // 为缓存的token延期
        $adminService->setLoginToken($adminService->getToken(),$adminService->getLoginId());

        return $next($request);
    }

}
